package com.ruoyi.system.mapper;

import java.util.List;

import com.ruoyi.system.domain.PoEventOpinionRelation;
import com.ruoyi.system.domain.PublicOpinionEvents;
import com.ruoyi.system.domain.PublicOpinionTopic;
import com.ruoyi.system.domain.vo.NameValue;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 事件Mapper接口
 * 
 * @author ruoyi
 * @date 2021-06-08
 */
public interface PublicOpinionEventsMapper 
{
    /**
     * 查询事件舆情关系列表
     *
     * @param eventId
     * @param relation
     * eventId 事件id
     * relation 事件和舆情
     * @return 事件舆情关系集合
     */
    @Select("select opinion_id FROM po_event_opinion_relation WHERE event_id = #{eventId} AND relation = #{relation}")
    List<String> selectOpinionsByEventRelation(@Param("eventId") Long eventId,@Param("relation") String relation);
    /**
     * 查询事件
     * 
     * @param eventId 事件ID
     * @return 事件
     */
    public PublicOpinionEvents selectPublicOpinionEventsById(Long eventId);

    /**
     * 查询事件列表
     * 
     * @param publicOpinionEvents 事件
     * @return 事件集合
     */

    public List<PublicOpinionEvents> selectPublicOpinionEventsList(PublicOpinionEvents publicOpinionEvents);

    /**
     * 新增事件
     * 
     * @param publicOpinionEvents 事件
     * @return 结果
     */
    public int insertPublicOpinionEvents(PublicOpinionEvents publicOpinionEvents);

    /**
     * 修改事件
     * 
     * @param publicOpinionEvents 事件
     * @return 结果
     */
    public int updatePublicOpinionEvents(PublicOpinionEvents publicOpinionEvents);

    /**
     * 删除事件
     * 
     * @param eventId 事件ID
     * @return 结果
     */
    public int deletePublicOpinionEventsById(Long eventId);

    /**
     * 批量删除事件
     * 
     * @param eventIds 需要删除的数据ID
     * @return 结果
     */
    public int deletePublicOpinionEventsByIds(Long[] eventIds);


    @Select("<script>select * from public_opinion_events where event_id in <foreach collection = 'eventIds' item ='id' index ='index' open='(' close=')' separator=','>#{id}</foreach></script>")
    @Results({
            @Result(column = "event_id", property = "eventId"),
            @Result(column = "event_title", property = "eventTitle"),
            @Result(column = "related_words", property = "relatedWords"),
            @Result(column = "opinion_words", property = "opinionWords"),
            @Result(column = "exclusion_words", property = "exclusionWords"),
    })
    List<PublicOpinionEvents> selectPublicOpinionEventsByIds(@Param("eventIds") Long[] eventIds);

    @Select("SELECT\n" +
            "\tsd.dict_label,\n" +
            "\tCOUNT(1) as count\n" +
            "FROM\n" +
            "\tpublic_opinion_events poe\n" +
            "LEFT JOIN sys_dict_data sd ON poe.incident_type = sd.dict_value\n" +
            "WHERE\n" +
            "\tsd.dict_type = 'event_type'\n" +
            "GROUP BY\n" +
            "\tdict_label")
    @Results({
            @Result(column = "dict_label", property = "name"),
            @Result(column = "count", property = "value"),
    })
    List<NameValue> getEventTypeCount();







    /**
     * 批量删除事件舆情关系
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deletePoEventOpinionRelationByIds(Long[] ids);


    /**
     * 新增事件舆情关系
     *
     * @param poEventOpinionRelation 事件舆情关系
     * @return 结果
     */
    public int insertPoEventOpinionRelation(PoEventOpinionRelation poEventOpinionRelation);


    /**
     * 查询事件舆情关系列表
     *
     * @param poEventOpinionRelation 事件舆情关系
     * @return 事件舆情关系集合
     */
    public List<PoEventOpinionRelation> selectPoEventOpinionRelationList(PoEventOpinionRelation poEventOpinionRelation);


    /**
     * 查询事件舆情关系列表
     *
     * @param poEventOpinionRelation
     * eventId 事件id
     * relation 事件和舆情
     * @return 事件舆情关系集合
     */
    public List<String> selectOpinionIdsByEventRelation(PoEventOpinionRelation poEventOpinionRelation);


}
